package com.CusterRelSys.control;

import com.CusterRelSys.entity.SalChance;
import com.CusterRelSys.entity.SalPlan;
import com.CusterRelSys.service.SalChanceService;
import java.util.List;

import com.CusterRelSys.service.SalPlanService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/SalChance")
public class SalChanceControl {
    @Resource
    private SalChanceService salChanceService;
    @Resource
    private SalPlanService salPlanService;
    @RequestMapping("/selectAll")
    public String selectSalChance(HttpSession session){
        System.out.println("====");
         List<SalChance> SalChance = salChanceService.selectSalChance();
            session.setAttribute("SaChance",SalChance);
        return "redirect:/~sale/dev.jsp";
    }
    @RequestMapping("/selectId")
    public String selectid(HttpServletRequest request,int chcId,HttpSession session){
        System.out.println(chcId);
        SalChance salChance = salChanceService.selectSalChanceId(chcId);
        System.out.println(salChance.toString());
        request.setAttribute("salChanceId",salChance);
        System.out.println("sad");
        List<SalPlan> salPlans = salPlanService.selectPlan(chcId);
        for (SalPlan salPlan : salPlans) {
            System.out.println(salPlan.toString());
        }
        session.setAttribute("salPlanId",salPlans);
        return "~sale/dev_plan";
    }
    @RequestMapping("/selectId2")
    public String selectId2(HttpServletRequest request,int chcId,HttpSession session){
        SalChance salChance = salChanceService.selectSalChanceId(chcId);
        request.setAttribute("salChanceId",salChance);
        List<SalPlan> salPlans = salPlanService.selectPlan(chcId);
        for (SalPlan salPlan : salPlans) {
            System.out.println(salPlan.toString());
        }
        session.setAttribute("salPlanId",salPlans);
        return "~sale/dev_execute";
    }
}
